package tangyaxin.www.saoerweima;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import dialog.ChangeColorWindow;

/**
 * Created by Administrator on 2016/7/9.
 */
public class QRMakeActivity extends Activity{
    private View bgLayout, changeColorBtn,shareBtn;
    private ImageView imgLayout;
    private ChangeColorWindow changeColorWindow;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_qr_make);
        findView();
        initView();
    }

    private void findView() {
        bgLayout=findViewById(R.id.qr_bg);
        changeColorBtn =findViewById(R.id.change_color_btn);
        shareBtn=findViewById(R.id.share_btn);
        imgLayout= (ImageView) findViewById(R.id.qr_img);
        changeColorWindow=new ChangeColorWindow(this);
    }

    private void initView() {
        changeColorBtn.setOnClickListener(onClickListener);
        shareBtn.setOnClickListener(onClickListener);
        changeColorWindow.setOnColorChangedListener(new ChangeColorWindow.OnColorChangedListener() {
            @Override
            public void onBgColorChanged(int color) {
                bgLayout.setBackgroundColor(color);
            }

            @Override
            public void onFgColorChanged(int color) {
                Toast.makeText(QRMakeActivity.this,"改变了前景色",Toast.LENGTH_LONG).show();
            }
        });

    }

    private View.OnClickListener onClickListener=new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()){
                case R.id.change_color_btn:
                    changeColorWindow.show(changeColorBtn);
                    break;
                case R.id.share_btn:

                    break;
            }
        }
    };
}
